<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body>
<ol id="mozToc">
<!--mozToc h1 1 h2 2 h3 3 h4 4 h5 5 h6 6--><li><a href="#mozTocId639784">How
to Compile the
Linux Kernel
    </a>
    <ol>
      <li>
        <ol>
          <li><a href="#mozTocId494433">Introduction
            </a></li>
          <li><a href="#mozTocId54533">Why Compile a New
Kernel?
            </a></li>
          <li><a href="#mozTocId348654">Getting the Kernel
Sources
            </a></li>
          <li><a href="#mozTocId335181">Configuring For a
Build</a></li>
          <li><a href="#mozTocId595530">Installing a New
Kernel</a></li>
          <li><a href="#mozTocId803284">Summary
            </a></li>
        </ol>
      </li>
      <li><a href="#mozTocId901005">Pop Goes the Kernel </a></li>
      <li><a href="#mozTocId475789">BTTV Module Parameters</a></li>
    </ol>
  </li>
</ol>
<br>
<hr style="width: 100%; height: 2px;">
<h2><a name="mozTocId639784" class="mozTocH2"></a>How to Compile the
Linux Kernel
</h2>
James Andrews
Saturday, May 29, 1999 01:36:47 PM
<br>
<br>
<h3><a name="mozTocId494433" class="mozTocH3"></a>Introduction
</h3>
RedHat is not Linux, it is a distribution based on the Linux kernel.
The Linux kernel is a complex program which provides the underlying
services to the rest of a Linux distribution. But it is easy to add new
features or improvments to it as, unlike commercial operating systems
like Windows 95 or MacOS, the source code is freely available. It is
common practice with a Linux based operating system to recompile the
kernel from source and much effort has been put in to make this a
realitively user-friendly experience.
<br>
<br>
<h3><a name="mozTocId54533" class="mozTocH3"></a>Why Compile a New
Kernel?
</h3>
You may be thinking "But why recompile it? It works fine as it is."
There are three reasons for a recompile. Firstly, you may have some
hardware that is so new that there's no kernel module for it in on your
distribution CD. Secondly, you may have come across some kind of bug
which is fixed in a revision of the operating system. Lastly, you may
have some new software which requires a newer version of the operating
system.
<br>
<br>
<h3><a name="mozTocId348654" class="mozTocH3"></a>Getting the Kernel
Sources
</h3>
The most recent releases of the kernel sources are available on
ftp.kernel.org. This site is mirrored worldwide so there is probably a
fast copy of it somewhere near you. Locate the file for the latest
version of the operating system and download it to /usr/src. Then issue
the tar zxf command to unpack it.
<br>
<br>
Alternatively, if you already have the kernel sources and only need to
upgrade one version number (from 2.2.1 to 2.2.2 for instance) then
download the patch file to /usr/src and then use the command:
<br>
<pre>gzip -dc patch-2.2.2.gz |patch -p0<br><br></pre>
to upgrade your old kernel sources. Patch files are much smaller to
download than the whole thing.
<br>
<br>
If you do not need the very latest version, then installing a kernel
source package from your distribution CD may be an easier way to
proceed.
<br>
<br>
<h3><a name="mozTocId335181" class="mozTocH3"></a>Configuring For a
Build</h3>
&nbsp;Change directory to /usr/src/Linux and issue the command:
<br>
<pre>make menuconfig<br></pre>
This will build a few programs and then quickly pop up a window. The
window menu lets you alter many aspects of kernel configuration.
<br>
After you have made any necessary changes, save the configuration and
follow these instructions--do a
<br>
<pre>make dep; make clean<br></pre>
The first of these commands builds the tree of interdependencies in the
kernel sources. These dependencies may have been affected by the
options you have choosen in the configure step. The make clean purges
any now-unwanted files left from previous builds of the kernel.
<br>
<br>
Then you are ready to go! Issue this command:
<br>
<pre>make zImage<br></pre>
and then, if you are on a machine slower than a Pentium 200, go and
make a cup of tea. This takes about 20 minutes on a Pentium 90...the
kernel has a lot of source code as you may have noticed when
downloading it. When this is complete do a:
<br>
<pre>make modules<br></pre>
This will not take as long.
<br>
<br>
<h3><a name="mozTocId595530" class="mozTocH3"></a>Installing a New
Kernel</h3>
Phew, finally! The last step is installing the new kernel. On an
Intel-based system the kernel is installed to the right place in /boot
with the command
<br>
<pre>cp /usr/Linux/src/arch/i386/boot/zImage /boot/newkernel<br></pre>
then
<br>
<pre>make modules_install<br></pre>
This will install the modules in /lib/modules.&nbsp; Next, edit
/etc/lilo.conf to add a section like this
<br>
<pre>image = /boot/newkernel<br>label = new<br>read-only<br></pre>
At the next reboot, select the kernel 'new' in lilo, and it will load
the new kernel. If it works fine, move it to the first position in the
lilo.conf so it will boot every time by default.
<br>
<br>
<h3><a name="mozTocId803284" class="mozTocH3"></a>Summary
</h3>
Compiling the kernel is a relatively simple operation- if you have done
it before! At first it can seem daunting. There are many Web sites
dedicated to the kernel; at the left are just a few.<br>
<hr style="width: 100%; height: 2px;">
<h2><a name="mozTocId901005" class="mozTocH2"></a>Pop Goes the Kernel -
2.6.1<br>
</h2>
Ref: APC Magazine March 2004<br>
<br>
<h3>Source Location</h3>
Unpack the linux source file in <span style="font-style: italic;">/usr/src/</span>
. This will create <span style="font-style: italic;">/usr/src/linux-2.6.1</span>
. Some 3rd party devices look for the kernel source in the default
directory, thus it is best to link this to the default directory by:<br>
<pre>$ln -s linux-2.6.1 linux</pre>
<h3>Preparation</h3>
This new kernel 2.6.1 requires a new tool called <span
 style="font-style: italic;">module-init-tools</span> that replaces <span
 style="font-style: italic;">modutils</span>. It can be found in <a
 href="www.kernel.org/pub/linux/people/rusty/modules">www.kernel.org/pub/linux/people/rusty/modules</a>.
This will generate <span style="font-style: italic;">/etc/modprobe.conf</span>
for those compiling from source:<br>
<pre>$./configure --prefix=/<br>$make moveold &amp;&amp; make<br>#make install<br>#./generate-modprobe.conf /etc/modprobe.conf<br>#depmod &lt;new-kernel-version&gt;<br></pre>
See <span style="font-style: italic;">Documentation/Changes</span>
file for more details.<br>
<h3><br>
Configuration</h3>
There are at least 4 ways to configure Linux. We will look at one way:<br>
<pre>$make menuconfig<br></pre>
Some kernel feature are built directly into the kernel while others are
loaded in at runtime. Use the following (from <span
 style="font-style: italic;">/sbin</span>) to check which features are
necessary:<br>
<ul>
  <li><span style="font-style: italic;">/etc/fstab</span> to see the
partitions</li>
  <li><span style="font-style: italic;">/boot/.config-VERSION</span>
has a copy of the default config file</li>
  <li><span style="font-style: italic;">lspci [-lvl]</span> lists the
PCI devices</li>
  <li><span style="font-style: italic;">lsmod</span> lists the
currently loaded modules</li>
  <li><span style="font-style: italic;">modinfo &lt;module&gt;</span>
displays info on specific modules</li>
</ul>
Kernel modules - those&nbsp; definitely required by the kernel - have
the extension <span style="font-style: italic;">*.ko</span> in version
2.6.1<br>
<h3>Compiling and Install</h3>
Use the following commands to build the kernel image, modules and then
copy install them into <span style="font-style: italic;">/boot<span
 style="font-style: italic;"> </span></span>and <span
 style="font-style: italic;">/lib/modules</span>:<br>
<pre>$make &amp;&amp; make modules<br>#make install<br></pre>
<h3>Update LILO</h3>
Add a new entry to the <span style="font-style: italic;">LILO</span>
boot manager:<br>
<pre><span style="font-style: italic;">LILO:</span><br>image=/boot/vmlinuz-2.6.1<br>	label=Linux<br>	read-only<br></pre>
After this, run<span style="font-style: italic;"> /sbin/lilo</span> for
the changes to take effect.<br>
<br>
<br>
<hr style="width: 100%; height: 2px;">
<h2><a name="mozTocId475789" class="mozTocH2"></a>BTTV Module Parameters</h2>
REF: http://freevo.sourceforge.net/cgi-bin/moin.cgi/BttvPage<br>
<br>
Do you have very poor color, very low volume and or channels off by one
or more channels? Check that the bttv module is correctly auto
detecting your card and tuner type.<br>
At a command promt type dmesg, the lines you are looking for look like<br>
<pre class="code">bttv0: detected: ATI TV Wonder/VE [card=64], PCI subsystem ID is 1002:0003 <br>bttv0: using: BT878(ATI TV-Wonder VE) [card=64,autodetected] <br>bttv0: using tuner=19 <br>bttv0: i2c attach [client=Temic PAL* auto (4006 FN5),ok] <br></pre>
<br>
My card is an ATI TV Wonder/VE so no changes are needed
here. Since I am in the US I need NTSC, and my tuner is made by Philips
(look at the metal box on the card) I did
<pre class="code">rmmod bttv <br>rmmod tuner <br>modprobe bttv tuner=2 <br></pre>
<br>
Note: You may need to set the card value as well
<pre class="code">modprobe bttv card=64 tuner=2 <br></pre>
<br>
this gives me the output
<pre class="code">bttv0: detected: ATI TV Wonder/VE [card=64], PCI subsystem ID is 1002:0003 <br>bttv0: using: BT878(ATI TV-Wonder VE) [card=64,autodetected] <br>bttv0: using tuner=2 <br>bttv0: i2c attach [client=Philips NTSC (FI1236 and compati,ok] <br></pre>
<br>
Thats it! Once you get the results you are looking for add the options
to your /etc/modules.conf<br>
add a line like
<pre class="code">options bttv card=64 tuner=2 <br></pre>
<p>run depmod after you are done modifying /etc/modules.conf </p>
<br>
<br>
<br>
<br>
</body>
</html>
